﻿
@using WebApp.Models
@model ManagementViewModel

@{
    ViewBag.Title = "角色配置管理";
}

<div id="content">


    <!-- quick navigation bar -->
    <div class="row">
        <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
            <h1 class="page-title txt-color-blueDark">
                <i class="fa fa-table fa-fw "></i>

                系统管理
                <span>
                    >
                    角色配置管理
                </span>
            </h1>
        </div>
        <div class="col-xs-12 col-sm-5 col-md-5 col-lg-8">

        </div>
    </div>
    <!-- end quick navigation bar -->
    <div class="row">
        <div class="col-sm-12">

            <div class="well">

                <div class="row">
                    <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <section id="widget-grid" class="">
                            <div class="widget-body ">

                                <div class="col-lg-12">

                                    <div class="col-md-4">
                                        <h3>角色</h3>
                                        <div style="padding-bottom:20px">
                                            @Html.Partial("_AddRolePartial", new RoleViewModel())
                                        </div>

                                        <div class="table-responsive">
                                            <table id="role-table" class="table table-bordered">
                                                <thead>
                                                    <tr>
                                                        <th>角色</th>
                                                        <th>操作</th>

                                                    </tr>
                                                </thead>
                                                @foreach (var role in Model.Roles)
                                                {
                                                    @Html.Partial("_RoleRecordPartial", role);
                                                }
                                            </table>
                                        </div>

                                    </div>
                                    <div class="col-md-8">
                                        <h3>用户</h3>

                                        <div class="table-responsive">
                                            <table id="account-table" class="table table-bordered">
                                                <thead>
                                                    <tr>
                                                        <th>账号</th>
                                                        <th>所属角色</th>
                                                        <th>追加角色</th>
                                                        <th>删除角色</th>
                                                    </tr>
                                                </thead>
                                                @foreach (var user in Model.Users)
                                                {
                                                    @Html.Partial("_AccountRecordPartial", new AccountRecordViewModel { User = user, Roles = Model.Roles })
                                                }
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </section>
                    </article>
                </div>

            </div>
        </div>
    </div>
</div>
@section Scripts {
    <script src="/Scripts/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
    <script type="text/javascript">
        //上传导入参数设定
        const entityname = "management";
        $(document).ready(function () {
            $('#addrolesform').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    Name: {
                        validators: {
                            notEmpty: {
                                message: '请输入新的角色'
                            }
                        }
                    }
                }
            });
            $('#adduserform').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    Name: {
                        validators: {
                            notEmpty: {
                                message: '请输入新的账号'
                            }
                        }
                    },
                    Email: {
                        validators: {
                            notEmpty: {
                                message: '请输入邮件地址'
                            },
                            emailAddress: {
                                message: '请输入有效的邮件地址'
                            }
                        }
                    },
                     Password: {
                        validators: {
                            notEmpty: {
                                message: '请输入密码'
                            }
                        }
                    }
                }
            });
        });
    </script>
 
}